<template>
  <div>
<h1>普通用户</h1>
股票名称:<input type="text" v-model="state.IName">
<input type="button" value="查询" @click="show">
<input type="button" value="排序" @click="pai()">
<table class="table table-bordered">
  <tr>
    <td>投资id</td>
    <td>投资项目</td>
    <td>投资总额度</td>
    <td>已投金额</td>
    <td>剩余额度</td>
    <td>投资人数</td>
  </tr>
  <tr v-for="item in list">
    <td>{{item.Iid}}</td>
    <td>{{item.IName}}</td>
    <td>{{item.IZongE}}</td>
    <td>{{item.IYiTou}}</td>
    <td>{{item.IShengYu}}</td>
    <td>{{item.INumber}}</td>
  </tr>
</table>
共<span>{{pcount}}</span>页
共<span>{{count}}</span>条
每页<span>{{state.pageSize}}</span>条
当前<span>{{state.pageIndex}}</span>/<span>{{pcount}}</span>页
<input type="button" value="首页" @click="page(1)">
<input type="button" value="上一页" @click="page(state.pageIndex-1)">
<input type="button" value="下一页" @click="page(state.pageIndex+1)">
<input type="button" value="尾页" @click="page(pcount)">
  </div>
</template>

<script setup lang="ts">
import {reactive,toRefs,onMounted} from  'vue'
import axios from 'axios'
import { useRoute,useRouter } from 'vue-router';
const router=useRouter()
const route=useRoute()

let data:any=reactive({
  state:{
    IName:'',
    pageIndex:1,
    pageSize:2,
    s:false
  },
   list:[],
   count:0,
   pcount:0,
})

let {state,list,count,pcount}=toRefs(data)

const pai=()=>{
if(state.value.s==false){
  state.value.s=true
}
else{
  state.value.s=false;
}
show()
}

const page=(y:any)=>{
  if(y>=1 && y<=pcount.value){
    state.value.pageIndex=y
  }
  show()
}

onMounted(()=>{
  show()
})

const show=()=>{
  axios({
    url:'/api/Users/GetInvestList',
    method:'get',
    params:state.value
  })
  .then(res=>{
    console.log(res);
    
    list.value=res.data.data.plist;
    count.value=res.data.data.count;
    pcount.value=res.data.data.pcount;

  })
  .catch(err=>{
    console.log(err);
    
  })

}
</script>

<style scoped>

</style>